package com.nifostasky.dlx.consumer;

import com.nifostasky.dlx.config.RabbitTtlDlxConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 延迟消息消费者
 */
@Slf4j
@Component
public class DelayConsumer {

    @RabbitListener(queues = {RabbitTtlDlxConfig.QUEUE_NAME_DEAD_LETTER})
    public void dlxQueue(Message message){
        log.info(new String(message.getBody()) + "，消息接收时间为：" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
    }
}
